// 
// Copyright 2010 Classpath Pty Ltd <opensource@classpath.com.au>
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// 

using build

**
** Tests the `CanUseColumnOptions` mixin.
**
internal class CanUseColumnOptionsTest : Test
{

    **
    ** Stores an instance of `CanUseColumnOptions` for testing.
    **
    CanUseColumnOptions? canUseColumnOptions

    **
    ** Performs additional setup needed for `CanUseColumnOptionsTest`.
    **
    override Void setup()
    {
        super.setup()
        canUseColumnOptions = CanUseColumnOptionsTestClass()
    }

    **
    ** Cleans up additional setup needed for `CanUseColumnOptionsTest`.
    **
    override Void teardown()
    {
        super.teardown()
        canUseColumnOptions = null
    }

    **
    ** Tests the `CanUseColumnOptions.autoIncrement` method.
    **
    Void testAutoIncrement() {
        option := canUseColumnOptions.autoIncrement
        verifyEq(AutoIncrementColumnOption#, option.typeof)
        verifyEq(1, canUseColumnOptions.modifications.size)
        verifyEq(option, canUseColumnOptions.modifications[0])
    }

    **
    ** Tests the `CanUseColumnOptions.comment` method.
    **
    Void testComment() {
        option := canUseColumnOptions.comment("comment")
        verifyEq(CommentColumnOption#, option.typeof)
        verifyEq("comment", (option as CommentColumnOption).comment)
        verifyEq(1, canUseColumnOptions.modifications.size)
        verifyEq(option, canUseColumnOptions.modifications[0])
    }

    **
    ** Tests the `CanUseColumnOptions.check` method.
    **
    Void testCheck() {
        option := canUseColumnOptions.check("check")
        verifyEq(CheckColumnOption#, option.typeof)
        verifyEq("check", (option as CheckColumnOption).check)
        verifyEq(1, canUseColumnOptions.modifications.size)
        verifyEq(option, canUseColumnOptions.modifications[0])
    }

    **
    ** Tests the `CanUseColumnOptions.defaultValue` method.
    **
    Void testDefaultValue() {
        option := canUseColumnOptions.defaultValue("default_value")
        verifyEq(DefaultValueColumnOption#, option.typeof)
        verifyEq("default_value", (option as DefaultValueColumnOption).defaultValue)
        verifyEq(1, canUseColumnOptions.modifications.size)
        verifyEq(option, canUseColumnOptions.modifications[0])
    }

    **
    ** Tests the `CanUseColumnOptions.notNull` method.
    **
    Void testNotNull() {
        option := canUseColumnOptions.notNull
        verifyEq(NotNullColumnOption#, option.typeof)
        verifyEq(1, canUseColumnOptions.modifications.size)
        verifyEq(option, canUseColumnOptions.modifications[0])
    }

    **
    ** Tests the `CanUseColumnOptions.primaryKey` method.
    **
    Void testPrimaryKey() {
        option := canUseColumnOptions.primaryKey
        verifyEq(PrimaryKeyColumnOption#, option.typeof)
        verifyEq(1, canUseColumnOptions.modifications.size)
        verifyEq(option, canUseColumnOptions.modifications[0])
    }

    Void testReferences() {
        option := canUseColumnOptions.references("table_name", "column_name")
        verifyEq(ReferencesColumnOption#, option.typeof)
        verifyEq("table_name", option.reference.table)
        verifyEq(1, option.reference.columns.size)
        verifyEq("column_name", option.reference.columns[0])
        verifyEq(1, canUseColumnOptions.modifications.size)
        verifyEq(option, canUseColumnOptions.modifications[0])
    }


    **
    ** Tests the `CanUseColumnOptions.unique` method.
    **
    Void testUnique() {
        option := canUseColumnOptions.unique
        verifyEq(UniqueColumnOption#, option.typeof)
        verifyEq(1, canUseColumnOptions.modifications.size)
        verifyEq(option, canUseColumnOptions.modifications[0])
    }

}

**
** Provides a simple implementation of `CanUseColumnOptions` for testing.
**
internal class CanUseColumnOptionsTestClass : CanUseColumnOptions {

    **
    ** Stores the list of [Modifications]`Modification` for testing.
    **
    override Modification[] modifications := [,]

}
